<?php
namespace app\admin\controller;
/**
 * 参与者
 */
class Participate extends Admin {
    /**
     * 当前模块参数
     */
    protected function _infoModule(){
        return array(
            'info'  => array(
                'name' => '参与者管理',
                'description' => '参与者管理',
            ),
            'menu' => array(
                array(
                    'name' => '参与者列表',
                    'url' => url('lists'),
                    'icon' => 'list',
                ),
            )
        );
    }
    /**
     * 列表
     */
    public function lists(){
        //筛选条件
        $where = array();
        $name = input('name');
        if(!empty($name)){
            $where['name'] = $name;
        }
        $mobile = input('mobile');
        if(!empty($mobile)){
            $where['mobile'] = $mobile;
        }
        //URL参数
        $pageMaps = array();
        $pageMaps['mobile'] = $mobile;
        $pageMaps['name'] = $name;
        //查询数据
        $limit=0;

        $list = db("member")->where($where)->paginate(20);
		
        //位置导航
        $breadCrumb = array('活动列表'=>url());
        //模板传值
        $this->assign('breadCrumb',$breadCrumb);
        $this->assign('list',$list);
        $this->assign('_page',$list->render());
        $this->assign('pageMaps',$pageMaps);
        return $this->fetch();
    }
    /**
     * 详情
     */
    public function info(){
		$activityId = input('id');
		$member_info = db("member")->find($activityId);
		$where['tel'] = $member_info['mobile'];
        $list = model('Sign')->loadList($where,100);

        if ($list){
            foreach ($list as $key => $value){
                $list[$key]['phone'] = $value['tel'];
                $userInfo = model('User')->getInfo($value['user_id']);

                if ($userInfo){
                    $list[$key]['user_name'] = $userInfo['nickname'];
                }else{
                    $list[$key]['user_name'] = '';
                }
                $activityInfo = model('Activity')->getInfo($value['activity_id']);
                if ($activityInfo){
                    $list[$key]['activity_title'] = $activityInfo['title'];
                }
            }
        }
        $this->assign('list',$list);
        return $this->fetch();
    }
}

